<template>
  <u-form-grid :data="formGrid"></u-form-grid>
</template>

<script>
  import values from '../../utils/values'

  export default {
    name: 'Customers',
    data() {
      return {
        formGrid: {
          options: {
            version: 'v2',
            url: {
              page: "/customers/coupons/page",
              save: "/customers/coupons/save",//记录添加和修改提交的地址，如果提交的对象有id则为修改
              delete: "/customers/coupons/delete",//记录删除的提交地址，通过提交id的集合来实现一个或者多个记录
              get: "/customers/coupons/find",//查看和编辑时用于查询对象的接口，参数为定义的keys
            }
          },
          tips: {"title": "优惠券管理", "content": "FormGrid是一个结合表单查询、修改、删除等全功能的组件。方便快速实现CRUD功能!"},

          form: {
            modal: {
              title: "优惠券信息"
            },
            columns: [
              {label: "所属客户", type: "text", name: "customerId", required: false},
              {label: "优惠券名称", type: "text", name: "name", required: false},
              {label: "使用开始日期", type: "date", name: "beginTime", required: false},
              {label: "使用结束日期", type: "date", name: "endTime", required: false,},
              {label: "来源", type: "select", name: "source", required: false, data: values.couponSource},
              {label: "描述信息", type: "text", name: "remark", required: false},
              {label: "是否启用", type: "select", name: "enabled", required: false, data: values.bool},
            ]
          },
          toolbar:{
            delete: { show :false }
          },
          table: {
            operation: {
              //调用查看、编辑、删除接口时，需要传递的参数主键名称，可以有多个。默认为id
              primaryKey: "id",
              buttons: [
                {key: "view", show: true, label: "查看", theme: "text", click: ( row, index, _this) => {
                  _this.optViewClick(row, index);
                }},
                {key: "edit", show: true, label: "编辑", theme: "primary", click: (row, index, _this) => {
                  _this.optEditClick(row, index);
                }},
              ]
            },
            columns: [
              {title: '所属客户', key: 'customerNickname'},
              {title: '优惠券名称', key: 'name'},
              {title: '使用开始日期', key: 'beginTime'},
              {title: '使用结束日期', key: 'endTime'},
              {title: '使用时最小商品价格', key: 'minGoodsPrice'},
              {title: '使用时最大商品价格', key: 'maxGoodsPrice'},
              {title: '描述信息', key: 'remark'},
              {title: '来源', key: 'source'},
              {title: '是否启用', key: 'enabled'},
            ]
          }
        }
      }
    },
    methods: {}
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
